In [1]:
%pylab inline
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
try:
from future.builtins import (bytes, str, open, super, range,
zip, round, input, int, pow, object)
except:
pass
# ---- Standard Libraries not included in pylab
import collections
import glob
import json
import random
import time
from StringIO import StringIO
# ---- Extra Libraries for additional functionality
import elasticsearch
from elasticsearch import Elasticsearch
es = Elasticsearch(['http://search-01.ec2.internal:9200'])
In [2]:
mapping = es.indices.get_mapping("gsod")
obs_mapping = collections.OrderedDict(mapping['gsod']['mappings']['observation']['properties'])
for ob_params in obs_mapping:
print("{:18s}{}".format(ob_params, obs_mapping[ob_params]))
In [3]:
%%bash
curl -XPUT 'http://search-01.ec2.internal:9200/gsod_test'
curl -XPUT 'http://search-01.ec2.internal:9200/gsod_test/_mapping/observation' -d '
{
"observation": {
"properties": {
"Num of Obs": {"type": "integer"},
"Wind Speed": {"type": "float"},
"FRSHTT": {"type": "string"},
"Snow Depth": {"type": "float"},
"Gust": {"type": "float"},
"SLP": {"type": "float"},
"Mean Temp": {"type": "float"},
"Max Wind Speed": {"type": "float"},
"Max Temp": {"type": "float"},
"STP": {"type": "float"},
"Min Temp": {"type": "float"},
"WBAN": {"type": "string"},
"Date": {"type": "date", "format": "dateOptionalTime"},
"Station Id": {"type": "string"},
"Dew Point": {"type": "float"},
"Precipitation": {"type": "float"},
"Visibility": {"type": "float"}
}
}
}'
In [4]:
mapping = es.indices.get_mapping("gsod_test")
obs_mapping = collections.OrderedDict(mapping['gsod_test']['mappings']['observation']['properties'])
for ob_params in obs_mapping:
print("{:18s}{}".format(ob_params, obs_mapping[ob_params]))
In [6]:
%%bash
curl -XDELETE 'http://search-01.ec2.internal:9200/gsod_test'
In [ ]:
%%bash
curl -XPUT 'http://search-01.ec2.internal:9200/gsod_test'
curl -XPUT 'http://search-01.ec2.internal:9200/gsod_test/_mapping/observation' -d '
{
"observation": {
"properties": {
"Num of Obs": {"type": "integer"},
"Wind Speed": {"type": "float"},
"FRSHTT": {"type": "string"},
"Snow Depth": {"type": "float"},
"Gust": {"type": "float"},
"SLP": {"type": "float"},
"Mean Temp": {"type": "float"},
"Max Wind Speed": {"type": "float"},
"Max Temp": {"type": "float"},
"STP": {"type": "float"},
"Min Temp": {"type": "float"},
"WBAN": {"type": "string"},
"Date": {"type": "date", "format": "dateOptionalTime"},
"Station Id": {"type": "string"},
"Dew Point": {"type": "float"},
"Precipitation": {"type": "float"},
"Visibility": {"type": "float"}
}
}
}'